package com.base.library.view.galleryViewPager;

import android.content.Context;
import android.view.ViewGroup;

import com.base.library.view.galleryImageView.FileTouchImageView;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：王东一 on 2015/8/6 13:36
 */
public class FilePagerAdapter extends BasePagerAdapter {
    private Context context;
    public ArrayList<FileTouchImageView> imageList = new ArrayList<FileTouchImageView>();

    public FilePagerAdapter(Context context, List<String> resources) {
        super(context, resources);
        this.context = context;
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
        ((GalleryViewPager) container).mCurrentView = ((FileTouchImageView) object)
                .getImageView();
    }

    @Override
    public Object instantiateItem(ViewGroup collection, int position) {
        final FileTouchImageView iv = new FileTouchImageView(mContext);
        iv.setUrl(mResources.get(position));
        iv.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        collection.addView(iv, 0);
        imageList.add(iv);
        return iv;
    }

}
